package com.lagou.mr.homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
/*
* mapTask的实现
* 主要获取文件的内容
* */
public class NumMapper extends Mapper<LongWritable, Text,NumBean, NullWritable> {
    final NumBean bean = new NumBean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //只有一个字段不需要切分
        final String numValue = value.toString();
        bean.setNum(Integer.parseInt(numValue));
        //bean对象作为key输出,value 为空
        context.write(bean,NullWritable.get());
    }
}
